package UnitTest.AlgorithmTest.backtrackTest;

import Algorithm.backtrack.CombinationNum;
import org.junit.Test;

import java.util.Arrays;
import java.util.List;

/**
 * @author liujun
 * @version 1.0
 * @date 2021/1/14
 * @author—Email liujunfirst@outlook.com
 * @blogURL https://blog.csdn.net/ljfirst
 * @description 组合数 测试案例
 */
public class CombinationNumTest {

    CombinationNum combinationNum = new CombinationNum();
    List<List<Integer>> list;
    List<Integer> list_temp;
    int[] answer_temp;

    @Test
    public void test() {
        list = combinationNum.getTergetList(demo01, target01);
        assert list.size() == answer01.length;
        for (int i = 0; i < list.size(); i++) {
            list_temp = list.get(i);
            answer_temp = list_temp.stream().mapToInt(Integer::intValue).toArray();
            assert Arrays.equals(answer_temp, answer01[i]);
        }
    }


    int[] demo01 = {1, 3, 6, 8, 5};
    int target01 = 9;
    int[][] answer01 = {
            {1, 8},
            {3, 6},
            {1, 3, 5},
            {3, 3, 3},
            {1, 1, 1, 6},
            {1, 1, 1, 1, 5},
            {1, 1, 1, 3, 3},
            {1, 1, 1, 1, 1, 1, 3},
            {1, 1, 1, 1, 1, 1, 1, 1, 1}};
}
